#!/usr/bin/env python
# encoding: utf-8

from flask_script import Manager, Server
from flask_migrate import Migrate, MigrateCommand
from app import app, db

# app=create_app('development')

# Init manager object via app object
manager=Manager(app)

migrate=Migrate(app,db)

# def make_shell_context():
    # return dict(app=app,db=db)
# Create a new commands: server
# This command will be run the Flask development_env server
# manager.add_command("shell",Shell(make_context=make_shell_context))
manager.add_command("server", Server())
manager.add_command('db',MigrateCommand)

@manager.shell
def make_shell_context():
    """Create a python CLI.

    return: Default import object
    type: `Dict`
    """
    # 确保有导入 Flask app object，否则启动的 CLI 上下文中仍然没有 app 对象
    return dict(app=app)

# @manager.command
# def myprint():
    # print('hello world')

if __name__ == '__main__':
    manager.run()
